<!-- Renders a form field with errors, required flags, and common styling.  
	html element fields such as class, style, or type can be passed as kwargs.
	Usage: macros.field(form.username, class="input-xlarge", type="email") -->
{% macro field(field, label='') -%}
            <div class="control-group{% if field.errors %} error{% endif %}">
            	{% set text = label or field.label.text %}
            	{% if field.flags.required %}
                	{{ field.label(text=text + " *", class="control-label") }}
                {% else %}
                	{{ field.label(text=text + " ", class="control-label") }}
                {% endif %}
                <div class="controls">
                {{ field(**kwargs) }}
                {% if field.errors %}
                    {% for error in field.errors %}<label for="{{ field.id }}" class="error help-inline">{{ error }}</label>{% endfor %}
                {% endif %}
                </div>
            </div>
{%- endmacro %}

<!-- renders federated login (openId and Oauth) login buttons -->
{% macro federated_login(provider_info, provider_uris, enable_federated_login) -%}
{% if enable_federated_login %}
            <div id="third_party_login" class="form-actions">
{#
                {% if disable_local_accounts %}
                <h4>{% trans %}Sign in using:{% endtrans %}</h4>
                {% else %}
#}
                <h4>{% trans %}Or Sign in using:{% endtrans %}</h4>
                <ul class="social-login-icons">
                    {% for p in provider_info if provider_uris[p] %}
                        <li><a href="{{ provider_uris[p] }}" class="social-btn social-btn-{{ p }}" title="{{ p }}">{{ p }}</a></li>
                    {% endfor %}
                </ul>
            </div>
{% endif %}
{%- endmacro %}
